//
//  CommonInforVC.m
//  NtoccShipper
//
//  Created by mac on 2019/11/9.
//  Copyright © 2019 zhuchongjin. All rights reserved.
//

#import "CommonInforVC.h"
#import "OpenInvoiceInfoVC.h"
#import "CommonRouteVC.h"

@interface CommonInforVC ()<UITableViewDelegate,UITableViewDataSource>
@property (strong, nonatomic) CJTableView *tableView;
@property (nonatomic,copy)NSArray *arrImgs;
@property (nonatomic,copy)NSArray *arrTitles;
@end

@implementation CommonInforVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setTitleName:CJLString(@"常用信息")];
    [self setBackLeftButton:@""];
    [self.view addSubview:self.tableView];
}

#pragma mark----tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arrTitles.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *MeViewCellId = @"cellId";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MeViewCellId];
    if (cell ==nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MeViewCellId];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        cell.textLabel.font = [UIFont cjTitleFont15];
        cell.textLabel.textColor = [UIColor cjMainTextColor];
    }
    
    cell.imageView.image = [UIImage imageNamed:self.arrImgs[indexPath.row]];
    CGSize itemSize = CGSizeMake(20, 20);
    UIGraphicsBeginImageContextWithOptions(itemSize, NO, UIScreen.mainScreen.scale);
    CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
    [cell.imageView.image drawInRect:imageRect];
    cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    cell.textLabel.text = self.arrTitles[indexPath.row];
    cell.separatorInset = UIEdgeInsetsMake(0.3f, 50.0f, 0.0f,0.0f);
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
        
    if (indexPath.row == 0)  {
        CommonRouteVC *vc  = [[CommonRouteVC alloc]init];
        vc.clickBack = NO;
        [self pushVc:vc];
    }else{
        OpenInvoiceInfoVC *vc = [[OpenInvoiceInfoVC alloc]init];
        [self pushVc:vc];
    }

}

- (NSArray *)arrTitles{
    
    if(!_arrTitles){
        _arrTitles = @[@"常用路线",@"开票信息"];
    }
    return _arrTitles;
}

- (NSArray *)arrImgs{
    if(!_arrImgs){
        _arrImgs = @[@"zcj_icon_send_address",@"zcj_icon_invoice_info"];
    }
    return _arrImgs;
}

- (CJTableView *)tableView{
    
    if (!_tableView) {
        _tableView = CJTableView.tbInitFrameStyle(CGRectMake(0,kTopHeight + CJTableToTopHeight, SCREEN_WIDTH, SCREEN_HEIGHT-kTopHeight - CJTableToTopHeight),UITableViewStylePlain)
        .tbDelegate(self)
        .tbDataSource(self)
        .tbSetOther(YES)
        .tbEstimatedRowHeight(YES)
        ;
    }
    
    return _tableView;
}

@end
